/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

/**
 *
 * @author PHANHAI
 */
public class Paging {
    private static final int NUM_PAGES = 5; 
    private int currentPage;
    private int[] pages;
    private int start;
    private int end;
    private boolean isPrev;
    private boolean isNext;

    public Paging(int currentPage) {
        if(currentPage <= 1) {
            isPrev = false;
            currentPage = 1;
        } else {
            isPrev = true;
        }
        isNext = true;
        start = 1 + ((int)((currentPage-1)/NUM_PAGES))*NUM_PAGES;
        end = start + NUM_PAGES - 1;
        this.currentPage = currentPage;
        pages = new int[NUM_PAGES];
    }
    
    public int getCurrentPage() {
        return currentPage;
    }

    public int[] getPages() {
        int j = 0;
        for(int i = start; i <= end; ++i) {
            pages[j++] = i;
        }
        return pages;
    }

    public boolean isIsNext() {
        return isNext;
    }

    public boolean isIsPrev() {
        return isPrev;
    }

    public void setIsNext(boolean isNext) {
        this.isNext = isNext;
    }
    
}
